Never unload print backends. Remove gtk_print_backend_unref_at_idle.
authorAlexander Larsson <alexl@redhat.com>
Mon, 15 May 2006 15:24:12 +0000 (15:24 +0000)
committerAlexander Larsson <alexl@src.gnome.org>
Mon, 15 May 2006 15:24:12 +0000 (15:24 +0000)
2006-05-15  Alexander Larsson  <alexl@redhat.com>

* gtk/gtk.symbols:
* gtk/gtkprintbackend.[ch]: (_gtk_print_backend_create):
Never unload print backends.
Remove gtk_print_backend_unref_at_idle.

* modules/printbackends/cups/gtkprintbackendcups.c:
(cups_dispatch_watch_finalize):
Don't use the unref_at_idle hack since that caused
deadlocks. Instead we never unload print backends, which
is not really a big problem.

ChangeLog
ChangeLog.pre-2-10
gtk/gtk.symbols
gtk/gtkprintbackend.c
gtk/gtkprintbackend.h
modules/printbackends/cups/gtkprintbackendcups.c

index 0c962a935632f36d5e559ab392a69a8822abae05..e01141b6d69a93851f4b2b70419db21d4ea52675 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-05-15  Alexander Larsson  <alexl@redhat.com>
+
+       * gtk/gtk.symbols: 
+       * gtk/gtkprintbackend.[ch]: (_gtk_print_backend_create):
+       Never unload print backends.
+       Remove gtk_print_backend_unref_at_idle.
+
+       * modules/printbackends/cups/gtkprintbackendcups.c:
+       (cups_dispatch_watch_finalize):
+       Don't use the unref_at_idle hack since that caused
+       deadlocks. Instead we never unload print backends, which
+       is not really a big problem.
+
 2006-05-14  Murray Cumming  <murrayc@murray.com>
 
        * gtk/gtkframe.c: Restored the / at the start of the comment 
index 0c962a935632f36d5e559ab392a69a8822abae05..e01141b6d69a93851f4b2b70419db21d4ea52675 100644 (file)
@@ -1,3 +1,16 @@
+2006-05-15  Alexander Larsson  <alexl@redhat.com>
+
+       * gtk/gtk.symbols: 
+       * gtk/gtkprintbackend.[ch]: (_gtk_print_backend_create):
+       Never unload print backends.
+       Remove gtk_print_backend_unref_at_idle.
+
+       * modules/printbackends/cups/gtkprintbackendcups.c:
+       (cups_dispatch_watch_finalize):
+       Don't use the unref_at_idle hack since that caused
+       deadlocks. Instead we never unload print backends, which
+       is not really a big problem.
+
 2006-05-14  Murray Cumming  <murrayc@murray.com>
 
        * gtk/gtkframe.c: Restored the / at the start of the comment 
index 2afc6788fb6864c98ceb538de6e8bc39e58dfc11..26d1226105bb7fc6d0cbeec1ead6b989861ae21b 100644 (file)
@@ -2559,7 +2559,6 @@ gtk_print_backend_printer_list_is_done
 gtk_print_backend_find_printer
 gtk_print_backend_print_stream
 gtk_print_backend_load_modules
-gtk_print_backend_unref_at_idle
 #endif
 #endif
 #endif
index 017b4c728385cbe48f125e8c120d2d21f65b792a..9bd1069a92a4039335c3246f317aada1757c4661 100644 (file)
@@ -227,6 +227,11 @@ _gtk_print_backend_create (const char *backend_name)
                                             pb_module);
 
          pb = _gtk_print_backend_module_create (pb_module);
+
+         /* Increase use-count so that we don't unload print backends.
+            There is a problem with module unloading in the cups module,
+            see cups_dispatch_watch_finalize for details. */
+         g_type_module_use (G_TYPE_MODULE (pb_module));
        }
       
       g_free (module_path);
@@ -521,19 +526,6 @@ gtk_print_backend_print_stream (GtkPrintBackend *backend,
                                                       dnotify);
 }
 
-static gboolean
-unref_at_idle_cb (gpointer data)
-{
-  g_object_unref (data);
-  return FALSE;
-}
-
-void
-gtk_print_backend_unref_at_idle (GtkPrintBackend *print_backend)
-{
-  g_idle_add (unref_at_idle_cb, print_backend);
-}
-
 void
 gtk_print_backend_destroy (GtkPrintBackend *print_backend)
 {
index 61021fcd9334329a85cc2e86b540da4532de851c..7f688ae0fc69eabf5f4f61de300396a9884905cf 100644 (file)
@@ -137,7 +137,6 @@ void        gtk_print_backend_print_stream         (GtkPrintBackend         *pri
                                                    gpointer                 user_data,
                                                    GDestroyNotify           dnotify);
 GList *     gtk_print_backend_load_modules         (void);
-void        gtk_print_backend_unref_at_idle        (GtkPrintBackend         *print_backend);
 void        gtk_print_backend_destroy              (GtkPrintBackend         *print_backend);
 
 /* Backend-only functions for GtkPrintBackend */
index 3380d8970d039f802a46259391143123f35d7809..006e5d446f256fae60f5aa55b9d586922c688941 100644 (file)
@@ -547,10 +547,15 @@ cups_dispatch_watch_finalize (GSource *source)
   if (dispatch->backend)
     {
       /* We need to unref this at idle time, because it might be the
-        last reference to this module causing the code to be
-        unloaded (including this particular function!)
-      */
-      gtk_print_backend_unref_at_idle (GTK_PRINT_BACKEND (dispatch->backend));
+       * last reference to this module causing the code to be
+       * unloaded (including this particular function!)
+       * Update: Doing this at idle caused a deadlock taking the
+       * mainloop context lock while being in a GSource callout for
+       * multithreaded apps. So, for now we just disable unloading
+       * of print backends. See _gtk_print_backend_create for the
+       * disabling.
+       */
+      g_object_unref (dispatch->backend);
       dispatch->backend = NULL;
     }